﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using University.Workshop.Presenters.Square.Modify;

namespace University.Workshop.Presentation.Square.Modify
{
    /// <summary>
    /// Interaction logic for PageSecondStepModifySquare.xaml
    /// </summary>
    public partial class PageSecondStepModifySquare : Page, ISecondStepForModifySquare
    {
        private PresenterSecondStepForModifySquare pSecondStepForModifySquare;
        private PresenterModifySquare pInternal;
        public PageSecondStepModifySquare(PresenterModifySquare pExternal)
        {
            InitializeComponent();
            pSecondStepForModifySquare=new PresenterSecondStepForModifySquare(this);
            pInternal = pExternal;
        }

        private void AddAllotmentbtn_Click(object sender, RoutedEventArgs e)
        {
            pSecondStepForModifySquare.AddAllotmentToList();
        }

        private void DeleteAllotmentDelete_Click(object sender, RoutedEventArgs e)
        {
            pSecondStepForModifySquare.DeleteAllotmentInList();
        }

        public ICollection<Model.Allotment> Allotments
        {
            get { return (ICollection<Model.Allotment>) AllotmentsDtgv.ItemsSource; }
            set
            {
                AllotmentsDtgv.ItemsSource = null;
                AllotmentsDtgv.ItemsSource = value;
            }
        }

        public string NameNewAllotment
        {
            get { return AllotmentNameTxBx.Text; }
            set { AllotmentNameTxBx.Text = value; }
        }

        public Model.Allotment AllotmentSelected
        {
            get
            {
                if (AllotmentsDtgv.SelectedItem == null)
                    return null;
                else
                    return (Model.Allotment)AllotmentsDtgv.SelectedItem;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public Model.Square SquareToModify
        {
            get; set; }

        public ICollection<Model.Allotment> AllotmentsToModify
        {
            get; set; }

        public void Update()
        {
            pSecondStepForModifySquare.UpdateData();
        }

        public string UbicationCroquisSquareToModify
        {
            get;
            set;
        }
        public string SystemMessage
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                pInternal.NotifySystemMessage(value);
            }
        }

        public string ErrorMessage
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                pInternal.NotifyErrorMessage(value);
            }
        }

        public void ChargeDataToBasic()
        {
            pSecondStepForModifySquare.ChargeDataMedicineProduct();
        }

        public void GoNextPage()
        {

        }

        public void GoBackPage()
        {
            pInternal.GoStepOne();
        }
    }
}
